replace removeLink with removeFile
authorJoey Hess <joeyh@joeyh.name>
Tue, 11 Feb 2025 17:41:26 +0000 (13:41 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 11 Feb 2025 17:41:26 +0000 (13:41 -0400)
same reasoning as in commit 5cc8d9d03b53f2e43d51e4f612f423178519e824

Annex/Content/PointerFile.hs
Annex/Content/Presence.hs
Annex/Fixup.hs
Annex/Ingest.hs
Annex/Link.hs
Annex/Tmp.hs
Annex/Transfer.hs
Build/DistributionUpdate.hs
Command/Fsck.hs

index c37614be943961175c011e874a5d360ea3de2966..22657a11c854158a07c1185ba7eebde5422a5484 100644 (file)
@@ -34,10 +34,9 @@ populatePointerFile :: Restage -> Key -> OsPath -> OsPath -> Annex (Maybe InodeC
 populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
   where
        go (Just k') | k == k' = do
-               let f' = fromOsPath f
                destmode <- liftIO $ catchMaybeIO $
-                       fileMode <$> R.getFileStatus f'
-               liftIO $ removeWhenExistsWith R.removeLink f'
+                       fileMode <$> R.getFileStatus (fromOsPath f)
+               liftIO $ removeWhenExistsWith removeFile f
                (ic, populated) <- replaceWorkTreeFile f $ \tmp -> do
                        ok <- linkOrCopy k obj tmp destmode >>= \case
                                Just _ -> thawContent tmp >> return True
@@ -55,11 +54,10 @@ populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
  - Does not check if the pointer file is modified. -}
 depopulatePointerFile :: Key -> OsPath -> Annex ()
 depopulatePointerFile key file = do
-       let file' = fromOsPath file
-       st <- liftIO $ catchMaybeIO $ R.getFileStatus file'
+       st <- liftIO $ catchMaybeIO $ R.getFileStatus (fromOsPath file)
        let mode = fmap fileMode st
        secureErase file
-       liftIO $ removeWhenExistsWith R.removeLink file'
+       liftIO $ removeWhenExistsWith removeFile file
        ic <- replaceWorkTreeFile file $ \tmp -> do
                liftIO $ writePointerFile tmp key mode
 #if ! defined(mingw32_HOST_OS)
index 1ef022c1ba9ac6d5e3b46ec60f0c1e3fc3290321..376e8d1a1dc388368076f056bfe4613229affda6 100644 (file)
@@ -116,7 +116,7 @@ inAnnexSafe key = inAnnex' (fromMaybe True) (Just False) go key
                                        Nothing -> return is_locked
                                        Just lockhandle -> do
                                                dropLock lockhandle
-                                               void $ tryIO $ removeWhenExistsWith R.removeLink lockfile
+                                               void $ tryIO $ removeWhenExistsWith removeFile lockfile
                                                return is_unlocked
                        , return is_missing
                        )
index f27ab45e38b27a7c517437a5b071b2c5117aab68..a0e5730333328f6a11e4d94fff6afcdf2fc86aed 100644 (file)
@@ -112,9 +112,8 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
 
        replacedotgit = whenM (doesFileExist dotgit) $ do
                linktarget <- relPathDirToFile w d
-               let dotgit' = fromOsPath dotgit
-               removeWhenExistsWith R.removeLink dotgit'
-               R.createSymbolicLink (fromOsPath linktarget) dotgit'
+               removeWhenExistsWith removeFile dotgit
+               R.createSymbolicLink (fromOsPath linktarget) (fromOsPath dotgit)
        
        -- Unsetting a config fails if it's not set, so ignore failure.
        unsetcoreworktree = void $ Git.Config.unset "core.worktree" r
index 47399567fc9f03ea672c7105557a1101139b093a..695a0cb0631804f539d28130d7419dacd5b99363 100644 (file)
@@ -120,7 +120,7 @@ lockDown' cfg file = tryNonAsync $ ifM crippledFileSystem
                                relatedTemplate $ fromOsPath $
                                        literalOsPath "ingest-" <> takeFileName file
                        hClose h
-                       removeWhenExistsWith R.removeLink (fromOsPath tmpfile)
+                       removeWhenExistsWith removeFile tmpfile
                        withhardlink' delta tmpfile
                                `catchIO` const (nohardlink' delta)
 
index 559add24ed1e8e7b6e39eed5de0508f9e04efa80..2f22143dd8bb06d63cecf2a0188785e945daef0e 100644 (file)
@@ -116,12 +116,10 @@ makeAnnexLink = makeGitLink
 makeGitLink :: LinkTarget -> OsPath -> Annex ()
 makeGitLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig)
        ( liftIO $ do
-               void $ tryIO $ R.removeLink file'
-               R.createSymbolicLink linktarget file'
+               void $ tryIO $ removeFile file
+               R.createSymbolicLink linktarget (fromOsPath file)
        , liftIO $ F.writeFile' file linktarget
        )
-  where
-       file' = fromOsPath file
 
 {- Creates a link on disk, and additionally stages it in git. -}
 addAnnexLink :: LinkTarget -> OsPath -> Annex ()
index 6a1fd99f7eb39bf8cbd1097f41b1fd552d6510e5..d6b18332cb79acd387aa2a612b4f0d8b758fa245 100644 (file)
@@ -61,7 +61,7 @@ cleanupOtherTmp = do
                tmpdir <- fromRepo gitAnnexTmpOtherDir
                void $ liftIO $ tryIO $ removeDirectoryRecursive tmpdir
                oldtmp <- fromRepo gitAnnexTmpOtherDirOld
-               liftIO $ mapM_ (cleanold . fromOsPath)
+               liftIO $ mapM_ cleanold
                        =<< emptyWhenDoesNotExist (dirContentsRecursive oldtmp)
                -- remove when empty
                liftIO $ void $ tryIO $ removeDirectory oldtmp
@@ -69,7 +69,7 @@ cleanupOtherTmp = do
        cleanold f = do
                now <- liftIO getPOSIXTime
                let oldenough = now - (60 * 60 * 24 * 7)
-               catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus f) >>= \case
+               catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus (fromOsPath f)) >>= \case
                        Just mtime | realToFrac mtime <= oldenough -> 
-                               void $ tryIO $ removeWhenExistsWith R.removeLink f
+                               void $ tryIO $ removeWhenExistsWith removeFile f
                        _ -> return ()
index c2fbfa5786a674c09e1074f337c694f003d93d32..45969003ae86a64bf195af9b984d88604a086f27 100644 (file)
@@ -216,7 +216,7 @@ runTransfer' ignorelock t eventualbackend afile stalldetection retrydecider tran
                 -}
                maybe noop dropLock moldlockhandle
                dropLock lockhandle
-               void $ tryIO $ R.removeLink lckfile
+               void $ tryIO $ removeFile lckfile
                maybe noop (void . tryIO . removeFile) moldlckfile
 #endif
 
index 80a0b2cdf3061fdba988a17c50d78cba451477b7..d864c7cf0971b4fe147d5bd1dda216f50c9595f8 100644 (file)
@@ -233,7 +233,7 @@ buildrpms topdir l = do
                <$> liftIO (getDirectoryContents rpmrepo)
        forM_ tarrpmarches $ \(tararch, rpmarch) ->
                forM_ (filter (isstandalonetarball tararch . fst) l) $ \(tarball, v) -> do
-                       liftIO $ mapM_ (removeWhenExistsWith (R.removeLink . toRawFilePath))
+                       liftIO $ mapM_ (removeWhenExistsWith removeFile)
                                (filter ((rpmarch ++ ".rpm") `isSuffixOf`) oldrpms)
                        void $ liftIO $ boolSystem script 
                                [ Param rpmarch
index d8f18bf16bf5a9095c6299f360d9bddf1c960724..4e66755c02b3049e6484a1c1f6c69165bbd282b0 100644 (file)
@@ -246,7 +246,7 @@ fixLink key file = do
                | want /= fromInternalGitPath have = do
                        showNote "fixing link"
                        createWorkTreeDirectory (parentDir file)
-                       liftIO $ R.removeLink (fromOsPath file)
+                       liftIO $ removeFile file
                        addAnnexLink (fromOsPath want) file
                | otherwise = noop